<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>创建文档</title>
    <link rel="stylesheet" href="/css/supervise/index.css">
    <link rel="stylesheet" href="/lib/layer/skin/default/layer.css">
    <link rel="stylesheet" href="/lib/laydate/need/laydate.css">
    <link rel="stylesheet" href="/lib/pagination/style/pagination.css">
    <script type="text/javascript" src="/js/jquery/jquery-1.9.1.js"></script>
    <script src="/lib/layer/layer.js?20201106"></script>
    <script src="/js/base/base.js"></script>
    <script src="/lib/laydate/laydate.js"></script>
    <script src="/lib/pagination/js/jquery.pagination.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/ueditor/ueditor.config.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/ueditor/ueditor.all.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/ueditor/UEcontroller.js" type="text/javascript" charset="utf-8"></script>

    <style>
       html,body,#word_container{
           height:100%;
           /*overflow: hidden;*/
        }
       body{
           overflow: hidden;
       }
       .clearfix:after{
           display: block;
           clear:both;
           height:0;
           content: "";
       }
        .edui-editor,.titles{
            height:85% !important;
        }
        .edui-editor-iframeholder{
            height:92% !important;
        }
       .input{
           width:500px !important;
           border-radius: 0 !important;
           height:26px !important;
           line-height: 26px !important;
       }
       input{
           width: 150px;
       }
        .titledocument{
            margin-top:20px;
            margin-bottom: 10px;
        }
        .titles{
            width:98%;
            margin:0 auto;
        }

        #keep{
            background: rgb(91, 192, 222);
            width: 100%;
            height:100%;
            line-height: 28px;
            color: #fff;
            cursor: pointer;
            text-align: center;
        }
       b{
           color: red;
           font-size: 18px;
           position: relative;
           top:5px;

       }
        table{
            table-layout: auto;
            width: 95%;
        }
    </style>
</head>
<body>
<div class="titles clearfix">
    <p class="titledocument">
        <span>文档标题：</span>
        <input id="articleTitle" class="input" type="text">

    </p>
    <div class="fl" style="width:78%;height:100%;margin-right:10px;position: relative">
        <b style="position:absolute;left: -20px;top: 30%;">*</b><div id="word_container" ></div>
    </div>
    <div class="fl clearfix" style="width:20%;margin-left: 5px">
        <table>
            <tr><td colspan="2"><p>基本属性</p></td></tr>
            <tr><td style="width: 100px">主标题:</td><td><b>*</b><input id="mainHead" type="text"></td></tr>
            <tr><td>副标题:</td><td><b>*</b><input id="subHead" type="text"></td></tr>
            <tr><td>关键字:</td><td><input id="keyWord" type="text"></td></tr>
            <tr style="height:100px;"><td>摘要:</td><td><b>*</b><textarea name="" id="articleSummary" style="height:90px;width:160px;margin-top: 10px;"></textarea></td></tr>
            <tr><td>来源:</td><td><input id="articleSource" type="text"></td></tr>
            <tr><td>作者:</td><td><input id="author" type="text"></td></tr>
            <tr><td>撰写时间:</td><td><b>*</b><input id="authorTime" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})" type="text"></td></tr>
            <%--<tr><td>创建时间:</td><td><b>*</b><input id="createTime" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})" type="text"></td></tr>--%>
            <tr>
                <td>是否置顶:</td><td>
                <select name="" id="topYn" style="width:100px;height:28px;">
                    <option value="0">不置顶</option>
                    <option value="1">置顶</option>
                </select>
            </td>
            </tr>
        </table>
    </div>
</div>
<%--<div style=" width: 105px;height: 28px;margin:0 auto;">--%>
    <%--<button id="keep">保存</button>--%>
<%--</div>--%>

<div style=" width: 200px;;margin:0 auto;">
    <button id="keep" style="width: 70px;height: 30px; background:rgb(92, 184, 92);border-color: rgb(76, 174, 76);border-radius: 3px">保存</button>
    <button  style="cursor: pointer;width: 70px;height: 30px; background:rgb(244, 244, 244);border:1px solid #dcdcdc;border-radius: 3px;margin-left: 20px" onclick="window.close();">关闭</button>
</div>

<script type="text/javascript">
    UE.getEditor('word_container',{elementPathEnabled : false})//展示ue文本框
    UEimgfuc();

    $(function(){
        function getParams(url) {//获取地址栏的参数
            if (!url)
                url = location.href;
            if (url.indexOf("?") !== -1)
            {
                var str = url.substr(url.indexOf("?") + 1) + "&";
                var strs = str.split("&");
                for (var i = 0; i < strs.length - 1; i++)
                {
                    var key = strs[i].substring(0, strs[i].indexOf("="));
                    var val = strs[i].substring(strs[i].indexOf("=") + 1);

                }
            }
            return val;
        }
        var chnlId = getParams();

//        if(extendid.indexOf("chnl")!=-1){//判断字符串里有么有chnl
//            str=""
//            for(i=0;i<extendid.length;i++) {//截取字符串数字
//                if("0123456789".indexOf(extendid.substr(i,1))>-1)
//                    str+=extendid.substr(i,1)
//            }
//            var columnid=str;
//        }

        $('#keep').click(function(){//保存
            var count=UE.getEditor('word_container').getContent();
            if(count==''){
                layer.msg('请填写内容', { icon:6});
                return false;
            }
            if($('#mainHead').val()==''){
                layer.msg('请填写主标题', { icon:6});
                return false;
            }
            if($('#subHead').val()==''){
                layer.msg('请填写副标题', { icon:6});
                return false;
            }
            if($('#articleSummary').val()==''){
                layer.msg('请填写摘要', { icon:6});
                return false;
            }
            if($('#authorTime').val()==''){
                layer.msg('请填写撰写时间', { icon:6});
                return false;
            }
//            if($('#createTime').val()==''){
//                layer.msg('请填写创建时间', { icon:6});
//                return false;
//            }
            var data={
                docTitle:$('#articleTitle').val(),//文档标题
                mainTitle:$('#mainHead').val(),//主标题
                subTitle:$('#subHead').val(),//副标题
                keyWords:$('#keyWord').val(),//关键字
                abstracts:$('#articleSummary').val(),//摘要
                source:$('#articleSource').val(),//来源
                author:$('#author').val(),//作者
                writeTimeDesc:$('#authorTime').val(),//撰写时间
//                createTime:$('#createTime').val(),//创建时间
                top:$('#topYn option:selected').val(),//是否置顶
                htmlContent:UE.getEditor('word_container').getContent(),//内容
                content:UE.getEditor('word_container').getContentTxt(),//内容
                chnlId:chnlId,
                category:0
            }
            $.ajax({
                url:'/cmsDocument/addDocument',
                type:'post',
                data:data,
                dataType:'json',
                success:function(){
                    window.opener.location.reload();//刷新父页面
                    window.close();
                }
            })

        })


    })
</script>
</body>
</html>
